<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>商城管理系统</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>
<style>
.main_div {
	min-width: 1000px
}

.pageChange {
	float: right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>


</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>退货管理</span>
					</div>
					<form class="form-inline" action="" method="post"
						style="margin-top: 30px;margin-left: 20px">
						<input style="display:none" value="10" id="pageCount"
							name="pageCount" />
						<div class="form-group">
							<label for="orderCode"> 订单编号:</label> <input type="text"
								class="form-control" id="orderCode">
						</div>
						<div class="form-group">
							<label for="ProductName"> 顾客名称:</label> <input type="text"
								class="form-control" id="userName" placeholder="">
						</div>
						<div class="form-group">
							<label for="userName"> 顾客电话:</label> <input type="text"
								class="form-control" id="phone">
						</div>
						<input onclick="selectinfo()" class="btn btn-primary"
							type="button" value="立即查询" />
					</form>
				</div>
				<div class="force-overflow1-1">
					<table class="table table-condensed table-bordered table-hover"
						show-filter="true" style="text-align: center" id="showtable">
						<tr style="background-color: #f8f8f8">
							<th style="text-align: center;color: #000">序号</th>
							<th style="text-align: center;color: #000">订单编号</th>
							<th style="text-align: center;color: #000">订单价格</th>
							<th style="text-align: center;color: #000">送货地址</th>
							<th style="text-align: center;color: #000">联系人</th>
							<th style="text-align: center;color: #000">电话</th>
							<th style="text-align: center;color: #000">理由</th>
							<th style="text-align: center;color: #000">留言</th>
							<th style="text-align: center;color: #000">退换时间</th>
							<th style="text-align: center;color: #000">查看详情</th>
							<th style="text-align: center;color: #000">立即处理</th>
						</tr>
					</table>
					<div class="bgBox" style="visibility:hidden">
						<div id="box">
							<div class="box_header textYellow">
								<span>详细资料</span>
							</div>
							<div class="scrollbar1-2" id="style1-1">
								<div class="box_content">
									<table class="table table-condensed table-bordered table-hover"
										style="text-align: center" id="showtable2">
										<tr>
											<th style="text-align: center">产品名称</th>
											<th style="text-align: center">产品单价</th>
											<th style="text-align: center">产品数量</th>
											<th style="text-align: center">产品总价</th>
										</tr>
									</table>
								</div>
								<div class="force-overflow1-2"></div>
							</div>
							<div class="box_footer">
								<ul>
									<li id="sureDetail" onclick="motaiHidden()">确认</li>
									<!-- <li id="prints" onclick="prints()">打印</li> -->
								</ul>
							</div>
						</div>
					</div>
					<div class="pageChange">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button type="submit" class="btn btn-primary"
							onclick="searchPage()">搜索</button>
					</div>
				</div>
			</div>
		</section>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		selectinfo();
	})
	function showMotais() { //弹出详情页面
		$(".bgBox").css("visibility", "visible")
	}
	function motaiHidden() { //隐藏详情页面
		$(".bgBox").css("visibility", "hidden")
	}
	function selectinfo() {
		var orderFormId = $("#orderCode").val();
		var phone = $("#phone").val();
		var userName = $("#userName").val();
		var pageNum = $("#pageNum").html();
		var pageCount = $("#pageCount").val();
		if (orderFormId == "") {
			orderFormId = null;
		}
		if (phone == "") {
			phone = null;
		}
		if (userName == "") {
			userName = null;
		}
		$.post(urls + "orderFormAction/getOrderFormBySuper",
			{
				superId : localStorage.getItem("directId"),
				orderFormId : orderFormId,
				typeId : 3,
				phone : phone,
				userName : userName,
				pageCount : pageCount,
				pageNum : pageNum,
				status : 5
			},
			function(data) {
				//console.log(data)
				if (data) {
					var totalpage = data.totalpage;
					var orderlist = data.orderlist;
					var table = $("#showtable");
					$("tr").remove(".addtr");
					for (var i = 0; i < orderlist.length; i++) {
						var returnCause;
						if (orderlist[i].returnCause == 0) {
							returnCause = "送货慢"
						} else {
							returnCause = "质量问题"
						}
						var append = "<tr class='addtr'><td>" + (i + 1) + "</td>" +
							"<td >" + orderlist[i].orderFormId + "</td>" +
							"<td>" + orderlist[i].totalMoney + "</td>" +
							"<td>" + orderlist[i].address + "</td>" +
							"<td>" + orderlist[i].userName + "</td>" +
							"<td>" + orderlist[i].phone + "</td>" +
							"<td>" + returnCause + "</td>" +
							"<td>" + orderlist[i].remark + "</td>" +
							"<td>" + orderlist[i].orderFormTime + "</td>" +
							"<td><input onclick='alertDetail(this)' id=" + orderlist[i].orderFormId + " type='button' class='btn btn-primary' value='查看详情' /></td>" +
							"<td><input onclick='returninfo(this)' id=" + orderlist[i].orderFormId + "|$" + orderlist[i].paymentType + " type='button' class='btn btn-primary' value='同意退货' /></td></tr>";
						table.append(append);
					}
					$("#totalpage").html(totalpage);
				}
			}
			, "json"
		)
	}
	function returninfo(e) { //退货	    
		var ids = e.id.split("|$")[0];
		var type = e.id.split("|$")[1];
		if (type == 2) {
			$.post(urls + "orderFormAction/returnTransferPay",
				{
					TransferNo : ids
				},
				function(res) {
					e.value = res.msg;
				}
			)
		}
	}
	function alertDetail(e) {
		var ids = e.id;
		showMotais()
		$.post(urls + "orderFormAction/getOrderFormDetailsByOrderFormID", {
			orderFormId : ids,
		}, function(res) {
			var tables = $("#showtable2");
			$(".addtr2").empty();
			for (var z in res) {
				var append = "<tr class='addtr2'><td >" + res[z].productName + "</td>" +
					"<td>" + res[z].unitPrice + "</td>" +
					"<td>" + res[z].quantity + "</td>" +
					"<td>" + res[z].totalPrices + "</td></tr>";
				tables.append(append);
			}
		})
	}
</script> 
</html>
